package cn.wit.test;

import java.util.Arrays;

/**
 * 数组倒置
 * 
 * @author 16604
 *
 */
public class DemoArraysReverse {
	public static void main(String[] args) {
		int[] nums = { 1, 2, 3, 4, 5 };
		
		System.out.println(Arrays.toString(nums));
		System.out.println(Arrays.toString(reverse(nums)));
	}

	public static int[] reverse(int[] nums) {

		int[] result = new int[nums.length];

		for (int i = nums.length - 1; i >= 0; i--) {
			result[i] = nums[nums.length - i - 1];
		}
		return result;
	}

}
